<template>
  <div style="overflow: auto">
    <el-container class="aside">
      <el-container class="main">
        <el-header style="height: 40%">
          <div class="main_header">
            <el-avatar :size="120" style="margin-top: 50px">
              <img :src="url" />
            </el-avatar>
            <div>
              <span style="font-size: 36px; font: bold">{{
                favoriteNum[0].userName
              }}</span>
              <i class="el-icon-male" v-if="favoriteNum[0].userSex == 1"></i>
              <i
                class="el-icon-female"
                v-else="favoriteNum[0].userSex == 2"
              ></i>
            </div>
            <div style="color: rgb(94, 90, 90)">
              <i class="el-icon-collection">{{invitenumber}}</i>
              <i class="el-icon-location-information">中国</i>
            </div>
          </div>
        </el-header>
        <el-main>
          <div class="main_content">
            <el-card class="box-card">
              <div slot="header" class="clearfix">
                <span style="float: left">最近的内容</span>
                <el-button
                  style="float: right; padding: 3px 0"
                  type="text"
                  @click="myinvite()"
                  >更多</el-button
                >
              </div>
              <div
                v-for="(item, index) in listDate1"
                :key="index"
                v-if="index < 6"
                class="text item"
              >
                <div class="card_item" @click="btnhead(item.inviteCode)">
                  <i
                    class="el-icon-paperclip"
                    style="
                      width: 100px;
                      float: left;
                      white-space: nowrap;
                      text-overflow: ellipsis;
                      overflow: hidden;
                    "
                    id="item_text"
                    >{{ item.inviteTitle }}</i
                  >
                  <i class="el-icon-timer" style="float: right"
                    >创建时间：{{ item.bytime}}</i
                  >
                </div>
              </div>
            </el-card>
          </div>
          <div class="main_content">
            <el-card class="box-card">
              <div slot="header" class="clearfix">
                <span style="float: left">最近的收藏</span>
                <el-button
                  style="float: right; padding: 3px 0"
                  type="text"
                  @click="shouchang()"
                  >更多</el-button
                >
              </div>
              <div
                v-for="(item, index) in listDate"
                :key="index"
                v-if="index < 7"
                class="text item"
              >
                <div class="card_item" @click="btnhead(item.inviteCode)">
                  <i
                    class="el-icon-paperclip"
                    style="
                      width: 100px;
                      float: left;
                      white-space: nowrap;
                      text-overflow: ellipsis;
                      overflow: hidden;
                    "
                    id="item_text"
                    >{{ item.inviteTitle }}</i
                  >
                  <i class="el-icon-timer" style="float: right"
                    >创建时间：{{ item.bytime}}</i
                  >
                </div>
              </div>
            </el-card>
          </div>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>
<script>
import { getUserByUserCode, } from "../api/user";
import { getListDateByUserCode,getSCListDateByUserCode } from "../api/cate";
export default {
  data() {
    return {
      userCode1: "",
      userCode: "",
      postNum: 1,
      replyNum: 1,
      listDate: [],
      listDate1: [],
      time: "",
      favoriteNum: [
        {
          userName: "",
          userSex: 1,
        },
      ],
      userName: "",
      url: "setup.png",
      name: "asdfadf",
      invitenumber:""
      // num: [{count, text: "累计发帖" }, {count, text: "累计回帖" }, {count, text: "累计收藏" }]
    };
  },
  mounted() {
    this.userName = sessionStorage.getItem("userName");
    this.url = sessionStorage.getItem("userUrl");
    this.userCode = sessionStorage.getItem("userCode");
    this.getData();
  },
  methods: {
    btnhead(val) {
      console.log(val);
      // this.$router.go(0)
      this.$router.replace({
        path: "/show",
        query: {
          inviteCode: val,
        },
      });
    },
    getData() {
      let obj = {
        userCode: this.userCode,
      };
      getUserByUserCode(obj).then((res) => {
        if (res.data.code === 200) {
          this.favoriteNum[0].userName = res.data.data.userName;
          this.favoriteNum[0].userSex=res.data.data.userSex;
          this.favoriteNum[0].userUrl=res.data.data.userUrl;
        } else {
          this.$message.error("查询失败失败");
        }
      });
      //模块1
     getSCListDateByUserCode(obj).then((res) => {
        if (res.data.code === 200) {
          this.listDate = res.data.data.ListData;
         
        } else {
          this.$message.error("没有数据");
          //  res.data.data.list
        }
      });

     getListDateByUserCode(obj).then((res) => {
        if (res.data.code === 200) {
          //   console.log(res.data.data.list);
          this.listDate1 = res.data.data.ListData;
          this.invitenumber=this.listDate1.length
        } else {
          this.$message.error("没有数据");
          //  res.data.data.list
        }
      });
    },
    shouchang() {
      this.$router.push("/mysc");
    },
    myinvite() {
      this.$router.push("/myinvite");
    },
    edit() {
      this.$router.push("/edit");
    },
  },
};
</script>

<style scoped>
.main_header {
  width: 100%;
  height: 40%;
  text-align: center;
  margin: 0px auto;
}
.medium {
  margin: -70px;
}

.count {
  margin-top: 50px;
  font-size: 30px;
}

.el-calendar {
  background-color: #fff;
  height: 58%;
}
.el-calendar-table .el-calendar-day {
  height: 32px;
}
.avatar {
  margin-top: 10px;
}
.name {
  margin-top: 10px;
}
.aside,
.main {
  height: 720px;
}
.el-header,
.el-footer {
  background-color: #7aa6df58;
  color: rgb(51, 48, 48);
  text-align: center;
}

.el-aside {
  color: #333;
}

.el-main {
  background-color: #e9eef3;
  color: #333;
  /* text-align: center; */
}
.el-carousel__item h3 {
  color: #475669;
  font-size: 14px;
  opacity: 0.75;
  line-height: 200px;
  margin: 0;
}

.el-carousel__item:nth-child(2n) {
  background-color: #99a9bf;
}

.el-carousel__item:nth-child(2n + 1) {
  background-color: #d3dce6;
}

.box-card {
  width: 100%;
  height: 100%;
}
.main_content {
  float: left;
  width: 45%;
  margin-left: 3%;
  height: 300px;
}

.card_item {
  display: flex;
  height: 20px;
  line-height: 20px;
  cursor: pointer;
  width: 100%;
  border-bottom: 0.5px solid rgba(0, 0, 0, 0.329);
}
.card_item:hover {
  color: rgb(4, 0, 255);
}
</style>
<style>
/* @import url(../login/reset.css);
#app {
  margin: 0;
  padding: 0;
} */

.text {
  font-size: 14px;
}

.item {
  margin-bottom: 18px;
}

.clearfix:before,
.clearfix:after {
  display: table;
  content: "";
}
.clearfix:after {
  clear: both;
}

.box-card {
  width: 480px;
}
</style>
